package cn.gson.crm.controller;

import cn.gson.crm.model.dao.DeliveryScheduleDetailsDao;
import cn.gson.crm.model.pojos.*;
import cn.gson.crm.model.service.DeliveryPlanService;
import cn.gson.crm.model.service.InvoiceService;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpSession;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Controller
@RequestMapping("/InvoiceController")
public class InvoiceController {
    @Autowired
    InvoiceService invoiceService;
    @Autowired
    DeliveryPlanService deliveryPlanService;
    @RequestMapping("/ContractMethod")
    @ResponseBody
    //查询当前人发货单
    public Map<String,Object> selectfahuo(HttpSession session, Integer yid, String dept, Integer page, Integer size){
        return invoiceService.selectfahuo(session,yid,dept,page,size);
    };
    @RequestMapping("/ContractMethod2")
    @ResponseBody
    //条件查询发货单
    public Map<String,Object> selectwhere(HttpSession session,Integer yid, String where,Integer page, Integer size){
        return invoiceService.selectwhere(session,yid,where,page,size);
    };
    @RequestMapping("/ContractMethod3")
    @ResponseBody
    //时间查询发货单
    public Map<String,Object> selecttime(HttpSession session,Integer yid,String statr,String endtime,Integer page, Integer size){

        return invoiceService.selecttime(session,yid,statr,endtime,page,size);
    };
    @RequestMapping("/ContractMethod4")
    @ResponseBody
    //根据订单id查询状态未交付的交付计划
    public List<DeliveryPlan> selectDelivery(Integer oid){
        return invoiceService.selectDelivery(oid);
    };
    @RequestMapping("/ContractMethod5")
    @ResponseBody
    //根据交付计划查询客户信息
    public Map<String,Object> selectcusomt(Integer cid,Integer pid){
        return invoiceService.selectcusomt(cid,pid);
    };
    @RequestMapping("/ContractMethod6")
    @ResponseBody
    //新增
    public void save(HttpSession session,@RequestBody  Invoice invoice){
        invoiceService.save(session,invoice);
    }
    @RequestMapping("/ContractMethod7")
    @ResponseBody
    public List<DeliveryScheduleDetails> select(Integer pid){
       return deliveryPlanService.dedeta(pid);
    }
    @RequestMapping("/ContractMethod8")
    @ResponseBody
    public List<Employee>selectem(Integer yid){
        return invoiceService.selectem(yid);
    };

    @RequestMapping("/ContractMethod9")
    @ResponseBody
    public void updatejiao(String pid){
        invoiceService.updatejiao(pid);
    };

    @RequestMapping("/ContractMethod10")
    @ResponseBody
    //发货操作
    public void fahuo(Integer oid,Integer pid,Integer lid){
        invoiceService.fahuo(oid,pid,lid);
    }
    @RequestMapping("/ContractMethod11")
    @ResponseBody
    public List<Invoice> selectfahuocustm(Integer cid){
        return   invoiceService.selectfahuocustm(cid);
    };
    @RequestMapping("/ContractMethod12")
    @ResponseBody
    //状态修改退换否
    public void updatefahuo(String tf, Integer lid){
        invoiceService.updatefahuo(tf,lid);
    };
}
